#![allow(dead_code)]

use core::option::Option::None;

#[derive(Debug, Clone)]
pub struct Manager {
    pub name: String,
}

pub struct Person {
    pub manager: Option<Manager>,
}

fn test() {
    let person = Person {
        manager: Some(Manager {
            name: "Mike".to_string(),
        }),
    };

    let p1 = person;

    let manager = person.manager.as_ref().unwrap();

    // compile error: cannot borrow `person` as mutable because it is also borrowed as immutable
    // mutable borrow occurs here
    let p_writer = &mut person;

    p_writer.manager = None;
    println!("{}", manager.name);
}
